﻿#include "MyPicture.h"
#include "TimeBase.h"

void test_picture()
{
    TimeBase time("test_picture");
    // 读取一张图片并显示
    MyPicture myPic(u8R"(Resource/Love-Live-Sunshine.jpg)");

    cv::Mat img = myPic.get_image();
    MyPicture::show_input_image("Love-Live-Sunshine", img);

    //myPic.print_image_info();
    //std::cout << "图片尺寸: " << myPic.get_image_height() << "x" << myPic.get_image_width() << std::endl;

    // 锐化图片
    myPic.sharpen_image(0.18f);

    // 去噪
    //myPic.bilateral_filter_image(3, 15, 12);
    //myPic.non_local_filter_image(3, 5, 19, 37);

    // 直方图均衡化
    //myPic.equalization_image();

    // 对比度限制自适应直方图均衡化
    myPic.clahe_image(2, 4);

    // 中值滤波
    //myPic.median_blur_image(3);

    // 高斯模糊
    //myPic.gaussian_blur_image(3, 0.5, 1.5);

    // 形态学操作
    //myPic.morphology_operations_image(cv::MORPH_GRADIENT, cv::MORPH_ELLIPSE, 3);

    // 调整图像的亮度、对比度和伽玛值
    //myPic.color_balance_image(0.9, 50, 1.1);

    // 阈值化分割
    //myPic.segment_image();

    // Canny边缘检测
    //myPic.edge_detection_canny_image(100, 200);

    // 掩码图像
    /*
    // 创建掩码图像（假设为与原始图像大小相同的单通道图像）
    cv::Mat mask = cv::Mat::zeros(myPic.get_image().size(), CV_8UC1);
    // 假设你想修复图像的某个矩形区域，可以在掩码图像上绘制白色矩形
    cv::Rect roi(50, 50, 100, 100); // 定义一个矩形区域 (x, y, width, height)
    cv::rectangle(mask, roi, cv::Scalar(255), -1); // 绘制白色矩形
    myPic.inpaint_image(mask, 3, cv::INPAINT_TELEA);
    */

    // 图像金字塔方法对图像进行上采样
    //myPic.pyramid_up_image();

    // 图像金字塔方法对图像进行下采样
    //myPic.pyramid_down_image();

    // 超分辨率
    //myPic.enhance_image_quality(R"(models\EDSR\EDSR_x4.pb)", "edsr", 4);

    // 压缩图片并保存
    //myPic.compress_image("Resource/Love-Live-Sunshine-edsr-x4.jpg", 80);

    myPic.show("after adjust");
}

